﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Util.Domains;

namespace IterationLife.FootballTeaching.Models {
    /// <summary>
    /// 用户课程
    /// </summary>
    [Description( "用户课程" )]
    public partial class UserCourse : AggregateRoot<UserCourse> {
        /// <summary>
        /// 初始化用户课程
        /// </summary>
        public UserCourse() : this( Guid.Empty ) {
        }

        /// <summary>
        /// 初始化用户课程
        /// </summary>
        /// <param name="id">用户课程标识</param>
        public UserCourse( Guid id ) : base( id ) {
        }

        /// <summary>
        /// 课程编号
        /// </summary>
        [Required(ErrorMessage = "课程编号不能为空")]
        public Guid CourseId { get; set; }
        /// <summary>
        /// 订阅状态
        /// </summary>
        [Required(ErrorMessage = "订阅状态不能为空")]
        public int SubscribeState { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreationTime { get; set; }
        /// <summary>
        /// 用户编号
        /// </summary>
        public Guid? UserId { get; set; }
        
        /// <summary>
        /// 课程
        /// </summary>
        public virtual Course Course { get; set; }
        
        /// <summary>
        /// 添加描述
        /// </summary>
        protected override void AddDescriptions() {
            AddDescription( "用户课程编", Id );
            AddDescription( "课程编号", CourseId );
            AddDescription( "订阅状态", SubscribeState );
            AddDescription( "创建时间", CreationTime );
            AddDescription( "用户编号", UserId );
        }
        
        /// <summary>
        /// 添加变更列表
        /// </summary>
        protected override void AddChanges( UserCourse newEntity ) {
            AddChange( "Id", "用户课程编", Id, newEntity.Id );            
            AddChange( "CourseId", "课程编号", CourseId, newEntity.CourseId );
            AddChange( "SubscribeState", "订阅状态", SubscribeState, newEntity.SubscribeState );
            AddChange( "CreationTime", "创建时间", CreationTime, newEntity.CreationTime );
            AddChange( "UserId", "用户编号", UserId, newEntity.UserId );
        }
    }
}